package com.sample.action;
/**
 * 家庭档案action
 */
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sample.action.form.FamilyrecordmessageForm;
import com.sample.javabean.Familyrecordmessage;
import com.sample.util.Pager;

/**
 * @version 1.0
 * @author Administrator
 *
 */
public class FamilyrecordmessageAction extends BaseAction {
		private final static Log log=LogFactory.getLog(FamilyrecordmessageAction.class);
		private Pager<Familyrecordmessage> pageList;
		private Familyrecordmessage familyrecordmessage=new Familyrecordmessage();
		private FamilyrecordmessageForm familyrecordmessageForm=new FamilyrecordmessageForm();
		private String family_id;

		/**
		 * 添加家庭档案
		 * @return
		 * @throws Exception
		 */
		public String inputFamilyrecordmessage()throws Exception{
			return "inputFamilyrecordmessage";
		}

		public String save()throws Exception{
			try{
				log.info("保存家庭档案信息");
				//familyrecordmessageForm属性接值，由struts2框架自动完成属性值注入
				if(familyrecordmessageForm!=null){
					Familyrecordmessage familyrecordmessage =new Familyrecordmessage();
					//将familyrecordmessageForm中的属性值一一赋予familyrecordmessage的对应的属性。
					familyrecordmessage.setCountyid(familyrecordmessageForm.getCountyid());
					familyrecordmessage.setTownid(familyrecordmessageForm.getTownid());
					familyrecordmessage.setGroupid(familyrecordmessageForm.getGroupid());
					familyrecordmessage.setFamily_id(familyrecordmessageForm.getFamily_id());
					familyrecordmessage.setFamilymaster(familyrecordmessageForm.getFamilymaster());
					familyrecordmessage.setCardNo(familyrecordmessageForm.getCardNo());
					familyrecordmessage.setVillageid(familyrecordmessageForm.getVillageid());
					familyrecordmessage.setBuildtime(familyrecordmessageForm.getBuildtime());
					familyrecordmessage.setId(familyrecordmessageForm.getId());


					//调用add方法
					familyrecordmessage.add();
				}
				return SUCCESS;
			}catch (Exception e) {
				e.printStackTrace();

			}
			return "inputFamilyrecordmessage";
		}
		
		/**
		 * 显示家庭档案
		 * @return
		 * @throws Exception
		 */
		public String list()throws Exception{
			Familyrecordmessage familyrecordmessageModel =new Familyrecordmessage();
			pageList =familyrecordmessageModel.list(page, size, familyrecordmessageForm);
			return "listFamilyrecordmessage";
		}
		
		/**
		 * 删除家庭档案
		 * @return
		 * @throws Exception
		 */
		public String del()throws Exception{
			try{
				if(familyrecordmessageForm!=null){
					familyrecordmessage.setFamily_id(family_id);
					familyrecordmessage.delFamilyrecordmessage();	
				}
				return SUCCESS;
			}catch (Exception e) {
				e.printStackTrace();
				throw e;
			}	
		}
		/**
		 * 编辑家庭档案
		 * @return
		 * @throws Exception
		 */
		public String editFamilyrecordmessage()throws Exception{
			try{
				familyrecordmessage.setFamily_id(family_id);
				familyrecordmessage.load();
				return "editFamilyrecordmessage";
			}catch (Exception e) {
				e.printStackTrace();
				throw e;
			}	
		}
		public String edit()throws Exception{
			try{
				if(familyrecordmessageForm!=null){
					familyrecordmessage.setCountyid(familyrecordmessageForm.getCountyid());
					familyrecordmessage.setTownid(familyrecordmessageForm.getTownid());
					familyrecordmessage.setGroupid(familyrecordmessageForm.getGroupid());
					familyrecordmessage.setFamily_id(familyrecordmessageForm.getFamily_id());
					familyrecordmessage.setFamilymaster(familyrecordmessageForm.getFamilymaster());
					familyrecordmessage.setCardNo(familyrecordmessageForm.getCardNo());
					familyrecordmessage.setVillageid(familyrecordmessageForm.getVillageid());
					familyrecordmessage.setBuildtime(familyrecordmessageForm.getBuildtime());
					familyrecordmessage.setId(familyrecordmessageForm.getId());
					familyrecordmessage.editFamilyrecordmessage();	
				}
				return SUCCESS;
			}catch (Exception e) {
				e.printStackTrace();
				throw e;
			}	
		}

		public Pager<Familyrecordmessage> getPageList() {
			return pageList;
		}

		public void setPageList(Pager<Familyrecordmessage> pageList) {
			this.pageList = pageList;
		}

		public Familyrecordmessage getFamilyrecordmessage() {
			return familyrecordmessage;
		}

		public void setFamilyrecordmessage(Familyrecordmessage familyrecordmessage) {
			this.familyrecordmessage = familyrecordmessage;
		}

		public FamilyrecordmessageForm getFamilyrecordmessageForm() {
			return familyrecordmessageForm;
		}

		public void setFamilyrecordmessageForm(
				FamilyrecordmessageForm familyrecordmessageForm) {
			this.familyrecordmessageForm = familyrecordmessageForm;
		}

		public String getFamily_id() {
			return family_id;
		}

		public void setFamily_id(String family_id) {
			this.family_id = family_id;
		}
		

	}
